Image processing method, electronic device, and computer-readable storage medium

ABSTRACT

An image processing method, an electronic device, and a computer-readable storage medium are provided. The method includes: obtaining N images; determining a reference image in the N images; where the reference image is an image in which a target tilt-shift object has a sharpness greater than a preset threshold; obtaining tilt-shift parameters input by a user, where the tilt-shift parameters are used to indicate an azimuth of a target focal plane and a tilt-shift area range; determining, based on the tilt-shift parameters, to-be-composited image(s) in intersection with the target focal plane; and performing, based on focal lengths of the to-be-composited image(s) and the reference image, image composite on the N images to output a target tilt-shift image.

CROSS-REFERENCE TO RELATED APPLICATIONS

This disclosure is continuation application of PCT InternationalApplication No. PCT/CN2021/072921 filed on Jan. 20, 2021, which claimspriority to Chinese Patent Application No. 202010075815.1, filed withthe China National Intellectual Property Administration on Jan. 22, 2020and entitled “IMAGE PROCESSING METHOD, ELECTRONIC DEVICE, ANDCOMPUTER-READABLE STORAGE MEDIUM”, which is incorporated herein byreference in its entirety.

TECHNICAL FIELD

The present invention relates to the field of image technologies, and inparticular, to an image processing method, an electronic device, and acomputer-readable storage medium.

BACKGROUND

Use of tilt-shift lenses to create tilt-shift photos with effects ofminiature models is common in photography industry.

Due to size limitation of electronic devices such as mobile phones andtablet computers, it is difficult to install a large tilt-shift lens inelectronic devices. In order to meet the needs of a user to taketilt-shift photos with electronic devices, methods of photo compositehave been used to simulate tilt-shift effects. In photographing, byrecording image field information of different photos, the differentphotos are composited based on the image field information to simulatetilt-shift effects.

However, it is difficult for the image field information recorded in theexisting composite methods to reflect a distance relationship betweenphotographed objects in real space, resulting in a miniature modeleffect not natural enough and a poor tilt-shift effect.

SUMMARY

According to a first aspect, an embodiment of the present inventionprovides an image processing method, applied to an electronic device,where the method includes:

-   -   obtaining N images, where the N images are taken based on a same        photographing location and have different in-focus subjects, and        the different in-focus subjects correspond to different focal        lengths;    -   determining a reference image in the N images, where the        reference image is an image in which a target tilt-shift object        has a sharpness greater than a preset threshold;    -   obtaining tilt-shift parameters input by a user, where the        tilt-shift parameters are used to indicate an azimuth of a        target focal plane and a tilt-shift area range;    -   determining, based on the tilt-shift parameters,        to-be-composited image(s) in intersection with the target focal        plane; and    -   performing, based on focal lengths of the to-be-composited        image(s) and the reference image, image composite on the N        images to output a target tilt-shift image.

According to a second aspect, an embodiment of the present inventionprovides an electronic device, where the electronic device includes:

-   -   an image obtaining module, configured to obtain N images, where        the N images are formed based on a same photographing location        and have different in-focus subjects, and the different in-focus        subjects correspond to different focal lengths;    -   a reference image determining module, configured to determine a        reference image in the N images, where the reference image is an        image in which a target tilt-shift object has a sharpness        greater than a preset threshold;    -   a tilt-shift parameter receiving module, configured to obtain        tilt-shift parameters input by a user, where the tilt-shift        parameters are used to indicate an azimuth of a target focal        plane and a tilt-shift area range;    -   a to-be-composited image determining module, configured to        determine, based on the tilt-shift parameters, to-be-composited        image(s) in intersection with the target focal plane; and    -   a composite processing module, configured to perform, based on        focal lengths of the to-be-composited image(s) and the reference        image, composite processing on the N images to output a target        tilt-shift image.

According to a third aspect, an embodiment of the present inventionprovides an electronic device, including a processor, a memory, and acomputer program stored in the memory and capable of running on theprocessor, where when the computer program is executed by the processor,the steps of the image processing method according to the first aspectare implemented.

According to a fourth aspect, an embodiment of the present inventionprovides a computer-readable storage medium, where the computer-readablestorage medium stores a computer program, and when the computer programis executed by a processor, the steps of the image processing methodaccording to the first aspect are implemented.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a flowchart of an image processing method according to anembodiment of the present invention;

FIG. 2 is a schematic diagram of a viewing window for a viewfinderaccording to an embodiment of the present invention;

FIG. 3 is a schematic diagram of N images according to an embodiment ofthe present invention;

FIG. 4 is a schematic diagram of a tilt-shift image according to anembodiment of the present invention;

FIG. 5 is a schematic diagram of tilt-shift parameters according to anembodiment of the present invention;

FIG. 6 is a schematic structural diagram of an electronic deviceaccording to an embodiment of the present invention; and

FIG. 7 is a schematic structural diagram of an electronic deviceaccording to an embodiment of the present invention.

DETAILED DESCRIPTION

The following clearly describes the technical solutions in theembodiments of this invention with reference to the accompanyingdrawings in the embodiments of this invention. Apparently, the describedembodiments are some but not all of the embodiments of this invention.All other embodiments obtained by a person of ordinary skill in the artbased on the embodiments of this invention without creative effortsshall fall within the protection scope of this invention.

It should be understood that “one embodiment” or “an embodiment”mentioned throughout the specification means that specified features,structures, or characteristics related to the embodiment are included inat least one embodiment of the present invention. Therefore, “in oneembodiment” or “in an embodiment” appearing throughout the specificationdoes not necessarily refer to a same embodiment. In addition, thesespecified features, structures, or characteristics may be combined inone or more embodiments in any appropriate manner.

It should be understood that in the embodiments of the presentinvention, sequence numbers of the following processes do not meanexecution sequences. The execution sequences of the processes should bedetermined based on functions and internal logic of the processes, butshould not be construed as any limitation on implementation processes ofthe embodiments of the present invention.

FIG. 1 is a flowchart of an image processing method according to anembodiment of the present invention. The method includes the followingsteps.

Step 101. Obtain N images, where the N images are taken based on a samephotographing location and have different in-focus subjects, and thedifferent in-focus subjects correspond to different focal lengths. It iseasy to understand that tilt-shifting can make up for a perspectivedistortion defect caused by a wide-angle lens, and achieve same visualeffects as a miniature model by changing an optical axis. In thetraditional camera field, in order to achieve a miniature model effect,a tilt-shift lens is used based on Scheimpflug principle, so that in ataken photo, some areas are sharp, and other areas are blurred. Thesharp areas are contrasted with the blurred areas, giving viewers avisual experience of a miniature model.

In the embodiments of the present invention, to achieve this miniaturemodel effect, N images may be obtained. The N images at least need tomeet the following condition: the images need to be taken on a samephotographing location and each has a different in-focus subject. Ifeach of the N images is taken at a different location, picture contentsof the images are different, so that subsequent alignment and compositecannot be performed on the images. It can be understood that toimplement image composite, N is at least 2. To ensure photographing atthe same location, the user can fix the device on a tripod tophotograph, or hold the device in hand and use a photographing angle anda photographing azimuth prompted by a virtual level on a screen to keepthe device stationary.

If an in-focus subject is different in each of the N images, subjectobjects that remain sharp in the different images are different. Becausewhen a photo is taken, a location of a camera is fixed and photographedsubjects in front of the camera are at different distances, focallengths of the in-focus subjects can be recorded in original imagecoding data (commonly known as raw data) of this photo. The focal lengthis a distance between the camera and the in-focus subject. Specifically,the distance generally refers to a distance between an image sensor andthe in-focus subject.

Taking a photographing scene described below in FIG. 2 as an example,through a viewfinder, a person, a car, a tree, and a mountain from nearto far distributed in front of the camera can be observed. As shown inFIG. 3 , when the person is selected as an in-focus subject for a focuspoint, the person in a captured image P1 is a sharp subject, andelements other than the person are blurred. When the car is selected asan in-focus subject for a focus point, the car in a captured image P2 isa sharp subject, and elements other than the car are blurred. When thetree is selected as an in-focus subject for a focus point, the tree in acaptured image P3 is a sharp subject, and elements other than the treeare blurred. When the mountain is selected as an in-focus subject for afocus point, the mountain in a captured image P4 is a sharp subject, andelements other than the mountain are blurred. It is easy to understandthat focal lengths of the in-focus subjects are recorded in the raws ofthe four images P1, P2, P3, and P4, respectively.

It can be understood that such N images may be taken by the user usinganother device, and transmitted from the another device to a devicecurrently performing image processing through a memory card orwirelessly, or may be taken by the device currently performing imageprocessing itself.

Specifically, the image obtaining in step 101 may be implemented by oneof Method 1 or Method 2 below.

Method 1: Stored when an electronic device performs a photographingoperation.

Sub-step 1. Perform a photographing operation on each of N differentin-focus subjects to obtain N images.

When the user uses the electronic device to photograph, the electronicdevice is fixed at one location. By touching a viewfinder screendisplayed in real time on a display, different photographing objects canbe selected, that is, different in-focus subjects can be selected. Afterone in-focus subject is selected and a long-press operation by the useris received, the camera can also automatically lock a focus location, soas to avoid focus failure due to out-of-focus. For example, when theuser chooses to focus on the car, the camera can briefly lock focus onthe car; and when the user chooses to focus on the person, the cameracan briefly lock focus on the person. After photographing operations areperformed separately for different in-focus subjects, N photos with asame number of in-focus subjects are taken.

Sub-step 2. Store the N images. Details may include:

A. Determine a focal length of each of the N different in-focus subjectswith respect to the camera.

Because the in-focus subjects in an actual scene are in athree-dimensional space, naturally a distance relationship exists amongthe in-focus subjects in front of the lens. Corresponding focal lengthsbetween the in-focus subjects and the camera can be calculated by usinga module of the camera such as a ultrasonic module, an infrared module,or a laser module, so that a distance parameter reference is providedfor image composite.

B. Sort the N images in order of their focal lengths.

Because the in-focus subjects in the images are different, the focallengths corresponding to the images are also not exactly the same andcan be arranged in order or in reverse order based on an order of thefocal lengths of the in-focus subjects in the N images. For example, inFIG. 5 , the in-focus subject in the image P1 is the person that isclosest to the camera, and the in-focus subject in the image P2 is thecar that is next closest to the camera. The in-focus subject in theimage P3 is the tree that is far from the camera. The in-focus subjectin the image P4 is the mountain that is farthest from the camera. The Nimages are arranged based on an order the focal lengths, which helpsreduce computational load of an image processor when searching for theto-be-composited images and save computing resources, and helps improveimage processing efficiency.

C. Store the sorted N images.

The sorted N images can be stored in a memory in groups. To facilitatesearching for the N images, specific identification character(s) canalso be added to attribute information of the N images in storing the Nimages.

Method 2: Obtain from another electronic device.

Sub-step 1. Access a target device through a removable storage medium orwirelessly.

When implementing the image processing method provided in thisapplication, in addition to processing the images taken by the currentdevice in real time, it is also possible to access another targetdevice, for example, another mobile phone, a computer, or a server, bymeans of a removable storage medium such as a memory card or a USB disk,or wirelessly by means of Bluetooth, Wi-Fi, and a mobile communicationnetwork.

Sub-step 2. Obtain N images prestored by the target device.

By reading the N images prestored in the memory of the target device,images in a device other than the current device can be processed togenerate tilt-shift images. It can be understood that the N images inthe target device in this case still need to meet the photographingrequirements of the foregoing step 101.

Step 102. Determine a reference image in the N images, where thereference image is an image in which a target tilt-shift object has asharpness greater than a preset threshold.

It should be noted that the miniature model effect is a visual effectthat is created after the image has been processed, and that thedecision as to which photographed object in an image is to betilt-shifted depends on psychological needs of the user. That is to say,a reference image needs to be determined by an electronic device fromthe N images in accordance with processing requirements of the user, andthe reference image is an image in which the target tilt-shift objecthas a sharpness greater than the preset threshold. In other words, basedon the already obtained N images, a sharp area in each image isdifferent. For example, as shown in FIG. 3 , the person in the image P1is sharp, the car in the image P2 is sharp, the tree in the image P3 issharp, and the mountain in the image P4 is sharp. In this embodiment ofthe present invention, which area is sharp and which area is blurred maybe determined according to magnitudes of contrast of different areas byperforming contrast identification on areas of each image, and an imagein which the target tilt-shift object on which the user wants to performtilt-shift processing has a sharpness greater than the preset thresholdis found from the N images and used as the reference image. The presetthreshold can be preset by a technician. It can be understood that ifthere are a plurality of images, each having a sharpness greater thanthe preset threshold, correspondingly, a most sharp image can beselected from the plurality of images with different sharpness values. Apicture presented on the reference image is that an area of the targettilt-shift object is clearly visible and an area outside the targettilt-shift object is blurred.

Specifically, the determination of the reference image in step 102 maybe implemented by a method below.

Sub-step 1. Receive object location information of the target tilt-shiftobject input by the user, where the object location information includesa location area at which the target tilt-shift object is located in theN images.

In the foregoing N images, same picture elements are recorded in eachimage. For example, as shown in FIG. 3 , each of the images P1 to P4 isa combination of a person, a car, a tree, and a mountain, and adifference lies in the in-focus subject. On the electronic device, theuser is presented with a visual effect resulted from a plurality ofstacking layers, each layer has an image, and the topmost layer is atransparent layer, which is used to receive input control information bythe user. The input control information is object location informationand may be one coordinate point or an area enclosed by severalcoordinate points. The object location information indicates a locationarea at which the target tilt-shift object is located in the N images.From this transparent layer, the user can see all the photographedobjects, and determine a particular object as the target tilt-shiftobject according to a tilt-shift result need. For example, taking thecar as the target tilt-shift object, the user touches a locationcorresponding to the car on a display, and the transparent layer canreceive a point- or area-touch signal and know that the user hasselected which photographed object as the target tilt-shift object.

Sub-step 2. Determine the reference image from the N images based on theobject location information. Details may include:

A. Obtain a sharpness of each of the N images.

A raw image is raw data of digital signals that converted by an imagesensor from captured light source signals. A raw file is a file thatrecords original information from a camera sensor and some metadata(such as sensitivity, shutter speed, aperture value, and white balance)generated by the camera in photographing. The in-focus subject in eachimage is different, which is specifically embodied in the raw file as adifference in pixel information. By analyzing raw data, the sharpness ofeach of the N images can be obtained, and specifically, a sharpnessdifference between different areas of any image can be obtained.

B. Determine an image in which the target tilt-shift object has asharpness greater than the preset threshold as the reference image.

Because the electronic device has received the object locationinformation about the target tilt-shift object input by the user, morespecifically, the electronic device has obtained information of auser-touch location. Based on the object location information, theelectronic device can know a sharpness of the location, that is, asharpness of the target tilt-shift object. The sharpness of the locationin each image can be compared with the preset threshold to filter out animage with a sharpness greater than the preset threshold as thereference image. It can be understood that the preset threshold needs tobe set according to empirical data during setting and that at least onereference image can be filtered out needs to be ensured.

Step 103. Obtain tilt-shift parameters input by a user, where thetilt-shift parameters are used to indicate an azimuth of a target focalplane and a tilt-shift area range.

After the reference image is selected, the electronic device receives anoperation by the user on the reference image. For example, if the userwants to perform tilt-shift processing on the car in FIG. 4 , the targettilt-shift object is the car and a corresponding reference image isdetermined as the image P2. The tilt-shift parameters input by the useron the reference image are obtained. With the tilt-shift parametersinput by the user on an operation screen, the azimuth of the targetfocal plane and the tilt-shift area range may be determined. The targetfocal plane is a plane at which a tilt-shift axis formed by connectingthe photographed objects is located, and the tilt-shift area is an areacorresponding to the tilt-shift effect.

Specifically, the tilt-shift parameters may include a target tilt-shiftpoint, a tilt-shift inclination, and a depth-of-field width. The targettilt-shift point is a coordinate location at which the target tilt-shiftobject is located. The target tilt-shift point input by the user on thereference image is a coordinate location at which the target tilt-shiftobject is located. It should be noted that the target tilt-shift pointmay be a coordinate point determined based on a user-touch signal, ormay be an area enclosed by several coordinate points determined based onthe user-touch signal. For example, when occupying a small proportion ofpixels in an image picture, the target tilt-shift object may be a point(for example, a bird photographed by using a wide-angle lens), and whenoccupying a large proportion of pixels in the image picture, the targettilt-shift object may be an area (for example, a building photographedby using the wide-angle lens). The tilt-shift inclination is an includedangle between the target focal plane at which the target tilt-shiftpoint is located and an imaging plane of the reference image, and thetarget focal plane is a plane at which a tilt-shift axis formed byconnecting photographed objects is located. The depth-of-field width isa width of an area with a tilt-shift effect.

For the obtaining of the tilt-shift parameters, an input box may be seton a touch screen so that the user can actively input the parameters, ora sliding bar or a virtual operation control reference line may be seton the touch screen so that the user can adjust the settings based onreal-time visual feedback, to achieve an input purpose, and thisembodiment of this application imposes no limitation thereon.

Step 104. Determine, based on the tilt-shift parameters,to-be-composited image(s) in intersection with the target focal plane.

After the electronic device obtains the foregoing tilt-shift parameters,a target focal plane that matches user needs can be constructed by usingthe tilt-shift parameters. Because the target focal plane is acombination of elements on each of the images, the target focal planeforms a virtual intersection with each of the images. However, not everyimage that intersects with the target focal plane may be used.Therefore, it is required to determine to-be-composited image(s)therefrom. It can be understood that in this embodiment of thisapplication, the target focal plane intersects with each of the images,and therefore the target focal plane is always a virtual imaginaryplane.

Specifically, when the tilt-shift parameters include the targettilt-shift point, the tilt-shift inclination, and the depth-of-fieldwidth, the determination of the to-be-composited image(s) in step 104may be implemented by the following method.

Sub-step 1. Determine, based on the target tilt-shift point and thetilt-shift inclination, a tilt-shift azimuth of the target focal plane.

The tilt-shift azimuth of the target focal plane can be uniquelydetermined based on the received target tilt-shift point and tilt-shiftinclination. In combination with illustrations of FIG. 4 and FIG. 5 , itis required to determine an azimuth of the target focal plane. After atarget tilt-shift point O is available, a location of a target focalplane M is determined, and in further combination with a tilt-shiftinclination a, a direction of its deflection can be known. Therefore,the imaginary target focal plane M corresponding to a tilt-shift axis mcan be found.

As illustrated in FIG. 4 , after the user has touched to select the caras the target tilt-shift object, a virtual straight line m can bedisplayed on the display. The straight line m always passes through theforegoing target tilt-shift point O. The user can control a direction ofthe straight line m by means of a slide, virtual adjustment buttons suchas a knob, or an input box provided on the display, so that the straightline m passes through other photographed objects on the picture thatneed to be tilt-shifted.

If the tree and the person are also needed to produce a silt-shifteffect, the straight line m needs to be controlled to pass through boththe tree and the person, and in this case, a tilt-shift inclination ofthe straight line m input by the user needs to be received. The straightline m formed by connecting the car, the tree, and the person is thetilt-shift axis, and the target focal plane M is a plane at which thestraight line m is located. The target focal plane M is determined basedon information input by the user, and is an imaginary focal plane anddifferent from a focal plane corresponding to the focus of the cameralens. The reference image P2 has an imaging plane parallel to the sensoron a side of a lens close to the sensor. Because the imaging plane isparallel to the image P2, the imaging plane is not shown separately. Asshown in FIG. 5 , the tilt-shift inclination is the included angle αbetween the target focal plane M at which the target tilt-shift point Ois located and the imaging plane of the reference image P2. There is aone-to-one correspondence between the included angle α and includedangles of the straight line m in different directions in FIG. 4 . Aninput of the included angle α can be completed when the user operatesand controls the azimuth of the straight line m on the display screen.

The tilt-shift azimuth of the target focal plane can therefore bedetermined based on the target tilt-shift point and the tilt-shiftinclination.

Sub-step 2. Determine, based on the tilt-shift azimuth and thedepth-of-field width, the to-be-composited image(s) in intersection withthe target focal plane.

The tilt-shift effect is to blur areas other than the tilt-shift area inthe image, and can conversely be regarded as a sharpening of thetilt-shift area. Accordingly, it is also necessary to know widthrange(s) to be processed on one or two sides of the tilt-shift axis m,or alternatively, a width of the area at which the tilt-shift effect islocated, that is, at least one of parameters a or b as shown in FIG. 4 .From the foregoing content, it is easy to understand that a tilt-shiftboundary straight line p corresponds to an imaginary focal plane P, anda tilt-shift boundary straight line q corresponds to an imaginary focalplane Q. It should be noted that a and b can be input by the userthrough the input box or determined by the user sliding a virtualslider.

With the determined tilt-shift azimuth of the target focal plane incombination with the depth-of-field width, it is easy to calculate atilt-shift area range to be processed. The tilt-shift area range isillustrated as a strip between the straight line p and the straight lineq in FIG. 4 and as a spatial area between the plane P and the plane Q inFIG. 5 .

As illustrated in FIG. 5 , the target focal plane M is in intersectionwith the N images in the tilt-shift area, and the intersection meansthat there are photographed objects on which tilt-shift processing needsto be processed in corresponding images, so that these images inintersection with the target focal plane can be determined asto-be-composited images that subsequently participate in composite.

It should be noted that the to-be-composited image(s) in intersectionwith the target focal plane include at least one of a firstto-be-composited image or a second to-be-composited image, where thefirst to-be-composited image is an image with a focal length less than areference distance in the N images, the second to-be-composited image isan image with a focal length greater than the reference distance in theN images, and the reference distance is a focal length of the referenceimage.

Taking the illustration in FIG. 5 as an example, the focal length of thereference image P2, which is the reference distance, is l₂, the focallength of the reference image P1 is l₁, the focal length of thereference image P3 is l₃, and the focal length of the reference image P4is l₄, where l₁>l₂>l₃>l₄. A method for filtering out to-be compositeimages P1 and P3 is as follows:

Based on the tilt-shift inclination a input by the user and thedepth-of-field widths a and b, it is easy to calculate a focal lengthcorresponding to a to-be-composited image as l_(pending)=l₂−a*tan α, andl′_(pending)=l₂ b*tan α, where l_(pending)<l₂, and l′_(pending)>l₂. Itcan be understood that either a or b can be zero, but both a and bcannot be zero. An image with a focal length between l_(pending) and l₂is the first to-be-composited image, and an image with a focal lengthbetween l₂ and l′_(pending) is the second to-be-composited image.

By receiving the parameters such as the target tilt-shift point,tilt-shift inclination, and depth-of-field width, which object in theimage that the user wants to perform tilt-shift processing on and atilt-shift processing range can be determined, and the to-be-compositedimage(s) are specifically determined.

Step 105. Perform, based on focal lengths of the to-be-compositedimage(s) and the reference image, image composite on the N images tooutput a target tilt-shift image.

A picture presented on the reference image is a picture where the targettilt-shift object appears sharp, the to-be-composited image(s) includeother photographed objects that require tilt-shift processing, and thefocal lengths of different images are different. Therefore, withcompositing based on the focal lengths of the images, a blur orsharpening range can be determined by considering distances of differentin-focus subjects in combination, so that the miniature model effect ofthe tilt-shift image is more realistic and natural.

Specifically, the image compositing process in step 105 may beimplemented in sub-step 1 or sub-step 2 below.

Sub-step 1. In a case that in-focus subject(s) of the to-be-compositedimage(s) intersect the target focal plane, stack and composite theto-be-composited image(s) and the reference image.

Each of the plurality of obtained to-be-composited images is determinedbased on an intersection relationship between the images and the targetfocal plane. However, the location at which the to-be-composited imageintersects the target focal plane is not necessarily the area at whichthe in-focus subject is located, which means that the intersectinglocation is not necessarily a sharp picture.

Therefore, when the in-focus subject(s) of the to-be-composited image(s)intersect the target focal plane, it can be learned that the areaintersecting the target focal plane in each image is sharp and meets therequirements of the tilt-shift effect. The in-focus subject(s) can becut out by using a matting algorithm and stacked and composited with thereference image. During the compositing, the tilt-shift area can belinearly processed based on the focal lengths. For example, thereference focal length is l₂, the focal length of the in-focus subjectthat is closest to the lens is l₁, with a sharpness of sls, and thefocal length of the in-focus subject that is farthest to the lens is l₃,with a sharpness of sle, so that a sharpness of the tilt-shift area canbe adjusted as sls−(l₃−l₂)(sls−sle)/(l₃−l₁). It should be noted that ahigher sharpness gives a sharper image, and a lower sharpness gives ablurrier image. Sharpness can be adjusted up or down.

Sub-step 2. In a case that the in-focus subject(s) of theto-be-composited image(s) do not intersect the target focal plane,perform, based on image(s) of the N images in which in-focus subject(s)intersect with the target focal plane, sharpness processing on thein-focus subject(s) of the to-be-composited image(s), and stack andcomposite the to-be-composited image(s) and the reference image.

When the in-focus subject(s) of the to-be-composited image(s) do notintersect the target focal plane, it can be learned that the areaintersecting the target focal plane in each image is blurred and cannotmeet the requirements of the tilt-shift effect. A degree of sharpnessmay be determined based on images adjacent to the image that does notsatisfy the tilt-shift effect. For example, the reference focal lengthis l₂, the focal length of the in-focus subject that is closest to thelens is l₁, with a sharpness of sls, and the focal length of thein-focus subject that is farthest to the lens is l₃, with a sharpness ofsle. When there are to-be-composited image(s) with blurred in-focussubject(s) between the image P1 and the image P2 or between the image P2and the image P3, sharpness(s) of the tilt-shift area(s) of theto-be-composited image(s) with blurred in-focus subject(s) can beadjusted as sls−(l₃−l₂)(sls−sle)/(l₃−l₁) with reference to thesharpnesses of image P1 and image P3.

Specifically, for the image composite in sub-step 1 or sub-step 2,reference may be made to the composite method below:

A. Cut out the in-focus subject(s) from the to-be-composited image(s)and set the in-focus subject(s) as a foreground layer.

For the filtered-out to-be-composited image, it is required to use apicture of its in-focus subject area. Therefore, mature algorithms suchas Bayesian matting algorithm can be used to cut out the in-focussubject from the to-be-composited image. A common understanding may bethat in each to-be-composited image after matting processing, areasother than the in-focus subject are transparent areas. It can beunderstood that when there are a plurality of to-be-composited images, aplurality of in-focus subjects need to be cut out. Correspondingly, allin-focus subjects are used as foreground layers to make up pictureelements in the tilt-shift area.

B. Set the reference image as a background layer.

It should be noted that the reference image is an image selected by theuser in an early stage of image processing. A distribution of a sharparea and a blurred area of the image meets use requirements. Therefore,the reference image is directly set as the background layer.

C. Stack and composite the foreground layer and the background layer.

Because each image is photographed at the same location, alignment ofpicture elements during compositing can be ensured. Therefore, after theforeground layer and the background layer are stacked and composited,the in-focus subject of the to-be-composited image that has been cut outcovers the same photographed subject in the reference image. In thisway, finally, a simulated tilt-shift image with a striped area in thepicture can be obtained.

In the embodiments of the present invention, the reference image and theto-be-composited image(s) are separately determined from a group of Nimages with different in-focus subjects. The reference image is an imagewith a sharp target tilt-shift object, that is, an image correspondingto a photographed object that needs to remain sharp in the tilt-shifteffect. The to-be-composited image(s) are other image(s) that aredetermined, based on the target tilt-shift point, the tilt-shiftinclination, and the depth-of-field width, intersecting the target focalplane. As a result, the reference image and the to-be-compositedimage(s) separately record focal length information of the differentin-focus subjects. The distance information can reflect a spatiallocation relationship of the different in-focus subjects in an imagepicture. Composite processing based on the focal lengths of theto-be-composited image(s) and the reference image can make a transitionbetween a sharp area and a blurred area in the composited tilt-shiftimage more natural and smooth, which can simulate a tilt-shift effectmore naturally and make a miniature model effect more realistic. Inaddition, in the tilt-shift image, images of different photographedobjects before and after the target tilt-shift object are used asto-be-composited images, making full use of the focal lengths to improvereality of the tilt-shift effect. Furthermore, using a plurality ofsorted images for image processing also helps improve image processingefficiency.

FIG. 6 is a block diagram of an electronic device. The electronic deviceincludes the following modules.

An image obtaining module 201 is configured to obtain N images, wherethe N images are formed based on a same photographing location and havedifferent in-focus subjects, and the different in-focus subjectscorrespond to different focal lengths.

A reference image determining module 202 is configured to determine areference image in the N images, where the reference image is an imagein which a target tilt-shift object has a sharpness greater than apreset threshold.

A tilt-shift parameter receiving module 203 is configured to obtaintilt-shift parameters input by a user, where the tilt-shift parametersare used to indicate an azimuth of a target focal plane and a tilt-shiftarea range.

Optionally, the tilt-shift parameters include a target tilt-shift point,a tilt-shift inclination, and a depth-of-field width. The targettilt-shift point is a coordinate location at which the target tilt-shiftobject is located; the tilt-shift inclination is an included anglebetween the target focal plane at which the target tilt-shift point islocated and an imaging plane of the reference image, the target focalplane being a plane at which a tilt-shift axis formed by connectingphotographed objects is located; and the depth-of-field width is a widthof an area with a tilt-shift effect.

A to-be-composited image determining module 204 is configured todetermine, based on the tilt-shift parameters, to-be-composited image(s)in intersection with the target focal plane.

Optionally, when the tilt-shift parameters include a target tilt-shiftpoint, a tilt-shift inclination, and a depth-of-field width, theto-be-composited image determining module 204 may include:

an azimuth determining sub-module, configured to determine, based on thetarget tilt-shift point and the tilt-shift inclination, a tilt-shiftazimuth of the target focal plane; and an image determining sub-module,configured to determine, based on the tilt-shift azimuth and thedepth-of-field width, the to-be-composited image(s) in intersection withthe target focal plane.

Optionally, the to-be-composited image(s) include at least one of afirst to-be-composited image or a second to-be-composited image, wherethe first to-be-composited image is an image with a focal length lessthan a reference distance in the N images, the second to-be-compositedimage is an image with a focal length greater than the referencedistance in the N images, and the reference distance is a focal lengthof the reference image.

A composite processing module 205 is configured to perform, based onfocal lengths of the to-be-composited image(s) and the reference image,composite processing on the N images to output a target tilt-shiftimage.

Optionally, the composite processing module 205 may include:

-   -   a first composite processing sub-module, configured to: in a        case that in-focus subject(s) of the to-be-composited image(s)        intersect the target focal plane, stack and composite the        to-be-composited image(s) and the reference image; and    -   a second composite processing sub-module, configured to: in a        case that the in-focus subject(s) of the to-be-composited        image(s) do not intersect the target focal plane, perform, based        on image(s) of the N images in which in-focus subject(s)        intersect with the target focal plane, sharpness processing on        the in-focus subject(s) of the to-be-composited image(s), and        stack and composite the to-be-composited image(s) and the        reference image.

Optionally, the first composite processing sub-module or the secondcomposite processing sub-module may include:

-   -   a foreground setting unit, configured to cut out the in-focus        subject(s) from the to-be-composited image(s) and set the        in-focus subject(s) as a foreground layer;    -   a background setting unit, configured to set the reference image        as a background layer; and    -   a stacking and compositing unit, configured to stack and        composite the foreground layer and the background layer.

The electronic device embodiment is essentially similar to the methodembodiment, and therefore is described briefly. For related informationand beneficial effects, refer to descriptions of the related parts inthe method embodiment.

An embodiment of the present invention further provides an electronicdevice, including:

-   -   a processor, a memory, and a computer program stored in the        memory and capable of running on the processor, where when the        computer program is executed by the processor, the steps of the        image processing method provided in the foregoing embodiments        are implemented. The electronic device provided in the        embodiments of the present invention is capable of implementing        processes that are implemented by the electronic device in the        method embodiments of FIG. 1 to FIG. 5 . To avoid repetition,        details are not described herein again.

FIG. 7 is a schematic diagram of a hardware structure of an electronicdevice for implementing the embodiments of the present invention.

The electronic device 500 includes but is not limited to components suchas a radio frequency unit 501, a network module 502, an audio outputunit 503, an input unit 504, a sensor 505, a display unit 506, a userinput unit 507, an interface unit 508, a memory 509, a processor 510,and a power supply 511. A person skilled in the art may understand thata structure of the electronic device shown in FIG. 7 constitutes nolimitation to the electronic device, and the electronic device mayinclude components more or fewer than those shown in the figure, orcombine some of the components, or arrange the components differently.In this embodiment of the present invention, the electronic deviceincludes but is not limited to a mobile phone, a tablet computer, anotebook computer, a palmtop computer, a vehicle-mounted terminal, awearable device, a pedometer, or the like.

The processor 510 is configured to: obtain N images, where the N imagesare taken based on a same photographing location and have differentin-focus subjects, and the different in-focus subjects correspond todifferent focal lengths;

-   -   determine a reference image in the N images, where the reference        image is an image in which a target tilt-shift object has a        sharpness greater than a preset threshold;    -   obtain tilt-shift parameters input by a user, where the        tilt-shift parameters are used to indicate an azimuth of a        target focal plane and a tilt-shift area range;    -   determine, based on the tilt-shift parameters, to-be-composited        image(s) in intersection with the target focal plane; and    -   perform, based on focal lengths of the to-be-composited image(s)        and the reference image, image composite on the N images to        output a target tilt-shift image.

In the embodiments of the present invention, the reference image and theto-be-composited image(s) are separately determined from a group of Nimages with different in-focus subjects. The reference image is an imagewith a sharp target tilt-shift object, that is, an image correspondingto a photographed object that needs to remain sharp in the tilt-shifteffect. The to-be-composited image(s) are other image(s) that aredetermined, based on the target tilt-shift point, the tilt-shiftinclination, and the depth-of-field width, intersecting the target focalplane. As a result, the reference image and the to-be-compositedimage(s) separately record focal length information of the differentin-focus subjects. The distance information can reflect a spatiallocation relationship of the different in-focus subjects in an imagepicture. Composite processing based on the focal lengths of theto-be-composited image(s) and the reference image can make a transitionbetween a sharp area and a blurred area in the composited tilt-shiftimage more natural and smooth, which can simulate a tilt-shift effectmore naturally and make a miniature model effect more realistic.

It should be understood that in this embodiment of the presentinvention, the radio frequency unit 501 may be configured to receive andtransmit signals in an information reception or transmission or callprocess. Specifically, after receiving downlink data from a basestation, the radio frequency unit 501 transmits the downlink data to theprocessor 510 for processing, and in addition, transmits uplink data tothe base station. Generally, the radio frequency unit 501 includes butis not limited to an antenna, at least one amplifier, a transceiver, acoupler, a low noise amplifier, a duplexer, and the like. In addition,the radio frequency unit 501 may further communicate with a network andother devices via a wireless communications system.

The electronic device provides wireless broadband Internet access for auser by using the network module 502, for example, helping the usertransmit and receive e-mails, browse web pages, and access streamingmedia.

The audio output unit 503 may convert audio data into an audio signal,and output the audio signal as sound, where the audio data is receivedby the radio frequency unit 501 or the network module 502, or stored inthe memory 509. In addition, the audio output unit 503 may furtherprovide audio output (for example, a call signal received sound or amessage received sound) related to a specific function performed by theelectronic device 500. The audio output unit 503 includes a speaker, abuzzer, a receiver, and the like.

The input unit 504 is configured to receive an audio signal or a videosignal. The input unit 504 may include a graphics processing unit(Graphics Processing Unit, GPU) 5041 and a microphone 5042. The graphicsprocessing unit 5041 processes image data of a static picture or a videocaptured by an image capture apparatus (for example, a camera) in animage capture mode or a video capture mode. A processed image frame maybe displayed on the display unit 506. The image frame processed by thegraphics processing unit 5041 may be stored in the memory 509 (oranother storage medium) or transmitted by using the radio frequency unit501 or the network module 502. The microphone 5042 can receive soundsand process such sounds into audio data. The processed audio data can beconverted into a format output that can be transmitted to a mobilecommunication base station through the radio frequency unit 501 in atelephone call mode.

The electronic device 500 further includes at least one sensor 505, forexample, an optical sensor, a motion sensor, and other sensors.Specifically, the optical sensor includes an ambient light sensor and aproximity sensor. The ambient light sensor may adjust brightness of adisplay panel 5061 based on intensity of ambient light. When theelectronic device 500 moves near an ear, the proximity sensor maydisable the display panel 5061 and/or backlight. As a type of motionsensor, an accelerometer sensor can detect magnitudes of accelerationsin all directions (usually three axes), can detect the magnitude anddirection of gravity when the electronic device is in a static state,and can be applied to electronic device posture recognition (such asscreen switching between portrait and landscape, related games, andmagnetometer posture calibration), functions related to vibrationrecognition (such as pedometer and tapping), and the like. The sensor505 may further include a fingerprint sensor, a pressure sensor, an irissensor, a molecular sensor, a gyroscope, a barometer, a hygrometer, athermometer, an infrared sensor, and the like. Details are not describedherein.

The display unit 506 is configured to display information input by theuser or information provided for the user. The display unit 506 mayinclude a display panel 5061. The display panel 5061 may be configuredin a form of a liquid crystal display (LCD), an organic light-emittingdiode (OLED), or the like.

The user input unit 507 may be configured to receive input digit orcharacter information, and generate key signal input that is related touser setting and function control of the electronic device.Specifically, the user input unit 507 includes a touch panel 5071 andother input devices 5072. The touch panel 5071 is also referred to as atouchscreen and can collect a touch operation (such as an operationperformed by the user on the touch panel 5071 or near the touch panel5071 with a finger or by using any proper object or accessory such as astylus) of the user on or near the touch panel 5071. The touch panel5071 may include two parts: a touch detection apparatus and a touchcontroller. The touch detection apparatus detects a touch direction of auser, detects a signal brought by a touch operation, and transmits thesignal to the touch controller. The touch controller receives touchinformation from the touch detection apparatus, converts the touchinformation into touch point coordinates, transmits the touch pointcoordinates to the processor 510, and receives and executes a commandtransmitted by the processor 510. In addition, the touch panel 5071 maybe implemented in a plurality of forms, for example, as a resistive,capacitive, infrared, or surface acoustic wave touch panel. In additionto the touch panel 5071, the user input unit 507 may further includeother input devices 5072. Specifically, the other input devices 5072 mayinclude but are not limited to a physical keyboard, a function key (suchas a volume control key or a switch key), a trackball, a mouse, and ajoystick. Details are not described herein.

Further, the touch panel 5071 may cover the display panel 5061. Afterthe touch panel 5071 detects a touch operation on or near the touchpanel 5071, the touch panel 5071 transmits the touch operation to theprocessor 510 to determine a type of a touch event. Then the processor510 provides a corresponding visual output on the display panel 5061based on the type of the touch event. In FIG. 7 , the touch panel 5071and the display panel 5061 serve as two separate components to implementinput and output functions of the electronic device. However, in someembodiments, the touch panel 5071 and the display panel 5061 may beintegrated to implement the input and output functions of the electronicdevice. This is not specifically limited herein.

The interface unit 508 is an interface for connecting an externalapparatus to the electronic device 500. For example, the externalapparatus may include a wired or wireless headphone port, an externalpower (or battery charger) port, a wired or wireless data port, a memorycard port, a port for connecting an apparatus with an identificationmodule, an audio input/output (I/O) port, a video I/O port, or anearphone port. The interface unit 508 may be configured to receive aninput (for example, data information or power) from an externalapparatus and transmit the received input to one or more elements withinthe electronic device 500, or may be configured to transmit data betweenthe electronic device 500 and the external apparatus.

The memory 509 may be configured to store software programs and variousdata. The memory 509 may mainly include a program storage area and adata storage area. The program storage area may store an operatingsystem, an application program required by at least one function (forexample, an audio play function or an image play function), and thelike. The data storage area may store data (for example, audio data anda phone book) created based on usage of the electronic device. Inaddition, the memory 509 may include a high-speed random access memory,and may further include a non-volatile memory such as a disk storagedevice, a flash memory device, or another volatile solid-state storagedevice.

The processor 510 is a control center of the electronic device, usesvarious interfaces and lines to connect all parts of the entireelectronic device, and performs various functions and data processing ofthe electronic device by running or executing the software programand/or module stored in the memory 509 and invoking data stored in thememory 509, thereby performing overall monitoring on the electronicdevice. The processor 510 may include one or more processing units.Preferably, the processor 510 may integrate an application processor anda modem processor. The application processor mainly processes theoperating system, a user interface, an application program, and thelike. The modem processor mainly processes wireless communication. Itmay be understood that the modem processor may alternatively not beintegrated in the processor 510.

The electronic device 500 may further include the power supply 511 (suchas a battery) that supplies power to the components. Preferably, thepower supply 511 may be logically connected to the processor 510 via apower management system, so that functions such as charge and dischargemanagement and power consumption management are implemented via thepower management system.

In addition, the electronic device 500 includes some functional modulesthat are not illustrated. Details are not described herein.

An embodiment of the present invention further provides acomputer-readable storage medium, where a computer program is stored inthe computer-readable storage medium. When the computer program isexecuted by a processor, each process of the foregoing informationprocessing method embodiment is implemented, with the same technicaleffect achieved. To avoid repetition, details are not described hereinagain. For example, the computer-readable storage medium is a read-onlymemory (ROM for short), a random access memory (RAM for short), amagnetic disk, an optical disc, or the like.

It should be noted that the terms “comprise”, “include”, or any of theirvariants in this specification are intended to cover a non-exclusiveinclusion, so that a process, a method, an article, or an apparatus thatincludes a list of elements not only includes those elements but alsoincludes other elements that are not expressly listed, or furtherincludes elements inherent to such process, method, article, orapparatus. In absence of more constraints, an element preceded by“includes a . . . ” does not preclude the existence of other identicalelements in the process, method, article, or apparatus that includes theelement.

According to the foregoing description of the implementations, a personskilled in the art may clearly understand that the methods in theforegoing embodiments may be implemented by using software incombination with a necessary common hardware platform, and certainly mayalternatively be implemented by using hardware. However, in most cases,the former is a preferred implementation. Based on such anunderstanding, the technical solutions of the present inventionessentially, or the part contributing to the prior art may beimplemented in a form of a software product. The software product isstored in a storage medium (for example, ROM/RAM, a magnetic disk, or anoptical disc), and includes several instructions for instructing aterminal (which may be a mobile phone, a computer, a server, an airconditioner, a network device, or the like) to perform the methoddescribed in the embodiments of the present invention.

The embodiments of the present invention are described above withreference to the accompanying drawings, but the present invention is notlimited to the foregoing implementations. The foregoing embodiments areonly illustrative rather than restrictive. Inspired by the presentinvention, a person of ordinary skill in the art can still derive manyvariations without departing from the essence of the present inventionand the protection scope of the claims. All these variations shall fallwithin the protection of the present invention.

What is claimed is:
 1. An image processing method, comprising: obtainingN images, wherein the N images are taken based on a same photographinglocation and have different in-focus subjects, and the differentin-focus subjects correspond to different focal lengths; determining areference image in the N images, wherein the reference image is an imagein which a target tilt-shift object has a sharpness greater than apreset threshold; obtaining tilt-shift parameters input by a user,wherein the tilt-shift parameters are used to indicate an azimuth of atarget focal plane and a tilt-shift area range; determining, based onthe tilt-shift parameters, to-be-composited image(s) in intersectionwith the target focal plane; and performing, based on focal lengths ofthe to-be-composited image(s) and the reference image, image compositeon the N images to output a target tilt-shift image.
 2. The methodaccording to claim 1, wherein the tilt-shift parameters comprise atarget tilt-shift point, a tilt-shift inclination, and a depth-of-fieldwidth; wherein the target tilt-shift point is a coordinate location atwhich the target tilt-shift object is located; the tilt-shiftinclination is an included angle between the target focal plane at whichthe target tilt-shift point is located and an imaging plane of thereference image, the target focal plane being a plane at which atilt-shift axis formed by connecting photographed objects is located;and the depth-of-field width is a width of an area with a tilt-shifteffect.
 3. The method according to claim 2, wherein the determining,based on the tilt-shift parameters, to-be-composited image(s) inintersection with the target focal plane comprises: determining, basedon the target tilt-shift point and the tilt-shift inclination, atilt-shift azimuth of the target focal plane; and determining, based onthe tilt-shift azimuth and the depth-of-field width, theto-be-composited image(s) in intersection with the target focal plane.4. The method according to claim 1, wherein the to-be-compositedimage(s) comprise at least one of a first to-be-composited image or asecond to-be-composited image, wherein the first to-be-composited imageis an image with a focal length less than a reference distance in the Nimages, the second to-be-composited image is an image with a focallength greater than the reference distance in the N images, and thereference distance is a focal length of the reference image.
 5. Themethod according to claim 1, wherein the performing, based on focallengths of the to-be-composited image(s) and the reference image, imagecomposite on the N images to output a target tilt-shift image comprises:in a case that in-focus subject(s) of the to-be-composited image(s)intersect the target focal plane, stacking and compositing theto-be-composited image(s) and the reference image; and in a case thatthe in-focus subject(s) of the to-be-composited image(s) do notintersect the target focal plane, performing, based on image(s) of the Nimages in which in-focus subject(s) intersect with the target focalplane, sharpness processing on the in-focus subject(s) of theto-be-composited image(s), and stacking and compositing theto-be-composited image(s) and the reference image.
 6. The methodaccording to claim 5, wherein the stacking and compositing theto-be-composited image(s) and the reference image comprises: cutting outthe in-focus subject(s) from the to-be-composited image(s) and settingthe in-focus subject(s) as a foreground layer; setting the referenceimage as a background layer; and stacking and compositing the foregroundlayer and the background layer.
 7. The method according to claim 1,wherein the obtaining N images comprises: performing a photographingoperation on each of N different in-focus subjects to obtain N images;and storing the N images.
 8. The method according to claim 1, whereinthe obtaining N images comprises: accessing a target device through aremovable storage medium or wirelessly; and obtaining N images prestoredby the target device.
 9. The method according to claim 7, wherein thestoring the N images comprises: determining a focal length of each ofthe N different in-focus subjects with respect to a camera; sorting theN images in order of their focal lengths; and storing the sorted Nimages.
 10. The method according to claim 1, wherein the determining areference image in the N images comprises: receiving object locationinformation of the target tilt-shift object input by the user, whereinthe object location information comprises a location area at which thetarget tilt-shift object is located in the N images; and determining thereference image from the N images based on the object locationinformation.
 11. The method according to claim 10, wherein thedetermining the reference image from the N images based on the objectlocation information comprises: obtaining a sharpness of each of the Nimages; and determining an image in which the target tilt-shift objecthas a sharpness greater than the preset threshold as the referenceimage.
 12. An electronic device, comprising a processor, a memory, and acomputer program stored in the memory and capable of running on theprocessor, wherein when the computer program is executed by theprocessor, the following steps are implemented: obtaining N images,wherein the N images are taken based on a same photographing locationand have different in-focus subjects, and the different in-focussubjects correspond to different focal lengths; determining a referenceimage in the N images, wherein the reference image is an image in whicha target tilt-shift object has a sharpness greater than a presetthreshold; obtaining tilt-shift parameters input by a user, wherein thetilt-shift parameters are used to indicate an azimuth of a target focalplane and a tilt-shift area range; determining, based on the tilt-shiftparameters, to-be-composited image(s) in intersection with the targetfocal plane; and performing, based on focal lengths of theto-be-composited image(s) and the reference image, image composite onthe N images to output a target tilt-shift image.
 13. The electronicdevice according to claim 12, wherein the tilt-shift parameters comprisea target tilt-shift point, a tilt-shift inclination, and adepth-of-field width; wherein the target tilt-shift point is acoordinate location at which the target tilt-shift object is located;the tilt-shift inclination is an included angle between the target focalplane at which the target tilt-shift point is located and an imagingplane of the reference image, the target focal plane being a plane atwhich a tilt-shift axis formed by connecting photographed objects islocated; and the depth-of-field width is a width of an area with atilt-shift effect.
 14. The electronic device according to claim 13,wherein the step of determining, based on the tilt-shift parameters,to-be-composited image(s) in intersection with the target focal planecomprises: determining, based on the target tilt-shift point and thetilt-shift inclination, a tilt-shift azimuth of the target focal plane;and determining, based on the tilt-shift azimuth and the depth-of-fieldwidth, the to-be-composited image(s) in intersection with the targetfocal plane.
 15. The electronic device according to claim 12, whereinthe to-be-composited image(s) comprise at least one of a firstto-be-composited image or a second to-be-composited image, wherein thefirst to-be-composited image is an image with a focal length less than areference distance in the N images, the second to-be-composited image isan image with a focal length greater than the reference distance in theN images, and the reference distance is a focal length of the referenceimage.
 16. The electronic device according to claim 12, wherein the stepof performing, based on focal lengths of the to-be-composited image(s)and the reference image, image composite on the N images to output atarget tilt-shift image comprises: in a case that in-focus subject(s) ofthe to-be-composited image(s) intersect the target focal plane, stackingand compositing the to-be-composited image(s) and the reference image;and in a case that the in-focus subject(s) of the to-be-compositedimage(s) do not intersect the target focal plane, performing, based onimage(s) of the N images in which in-focus subject(s) intersect with thetarget focal plane, sharpness processing on the in-focus subject(s) ofthe to-be-composited image(s), and stacking and compositing theto-be-composited image(s) and the reference image.
 17. The electronicdevice according to claim 12, wherein the step of obtaining N imagescomprises: performing a photographing operation on each of N differentin-focus subjects to obtain N images; and storing the N images.
 18. Theelectronic device according to claim 12, wherein the step of determininga reference image in the N images comprises: receiving object locationinformation of the target tilt-shift object input by the user, whereinthe object location information comprises a location area at which thetarget tilt-shift object is located in the N images; and determining thereference image from the N images based on the object locationinformation.
 19. The electronic device according to claim 18, whereinthe step of determining the reference image from the N images based onthe object location information comprises: obtaining a sharpness of eachof the N images; and determining an image in which the target tilt-shiftobject has a sharpness greater than the preset threshold as thereference image.
 20. A non-transitory computer-readable storage medium,wherein the computer-readable storage medium stores a computer program,and when the computer program is executed by a processor, the followingsteps are implemented: obtaining N images, wherein the N images aretaken based on a same photographing location and have different in-focussubjects, and the different in-focus subjects correspond to differentfocal lengths; determining a reference image in the N images, whereinthe reference image is an image in which a target tilt-shift object hasa sharpness greater than a preset threshold; obtaining tilt-shiftparameters input by a user, wherein the tilt-shift parameters are usedto indicate an azimuth of a target focal plane and a tilt-shift arearange; determining, based on the tilt-shift parameters, to-be-compositedimage(s) in intersection with the target focal plane; and performing,based on focal lengths of the to-be-composited image(s) and thereference image, image composite on the N images to output a targettilt-shift image.